local extension = Package("fengqi_fire")
extension.extensionName = "aaa_fengqi"

local U = require "packages/utility/utility"

Fk:loadTranslationTable{
  ["fengqi_fire"] = "火",
}


local yuanshao = General(extension, "efengqi__yuanshao", "qun", 4)

local efengqi__qunni = fk.CreateViewAsSkill{
  name = "efengqi__qunni",
  anim_type = "offensive",
  pattern = "wild_revolt",
  prompt = "#efengqi__qunni",
  card_filter = function(self, to_select, selected)
    return #selected < 2
  end,
  view_as = function(self, cards)
    if #cards ~= 2 then return nil end
    local c = Fk:cloneCard("wild_revolt")
    c.skillName = self.name
    c:addSubcards(cards)
    return c
  end,
  before_use = function (self, player, use)
    use.extra_data = use.extra_data or {}
    use.extra_data.efengqi__qunniFrom = player.id
  end,
}

local efengqi__qunni_trigger = fk.CreateTriggerSkill{
  name = "#efengqi__qunni_trigger",
  anim_type = "drawcard",
  frequency = Skill.Compulsory,
  events = {fk.Deathed},
  main_skill = efengqi__qunni,
  can_trigger = function(self, event, target, player, data)
    return not player.dead and data.damage and data.damage.from == player and data.damage.card
    and table.contains(data.damage.card.skillNames, "efengqi__qunni")
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local pile = room:getBanner("@$CenterArea") or {}
    if #pile > 0 then
      room:obtainCard(player, table.random(pile), true, fk.ReasonJustMove, player.id, "efengqi__qunni")
    end
  end,

  refresh_events = {fk.PreDamage},
  can_refresh = function (self, event, target, player, data)
    if data.card and table.contains(data.card.skillNames, "efengqi__qunni") then
      local e = player.room.logic:getCurrentEvent():findParent(GameEvent.UseCard)
      if e then
        local use = e.data[1]
        return use.card == data.card and use.extra_data and use.extra_data.efengqi__qunniFrom == player.id
      end
    end
  end,
  on_refresh = function (self, event, target, player, data)
    data.from = player
  end,
}
efengqi__qunni:addRelatedSkill(efengqi__qunni_trigger)

efengqi__qunni.CenterArea = true
yuanshao:addSkill(efengqi__qunni)

local efengqi__zongyi = fk.CreateTriggerSkill{
  name = "efengqi__zongyi", -- 主公技无法检测隐匿……
  anim_type = "control",
  events = {fk.BuryVictim},
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self) and data.damage and data.damage.from == player and target.rest == 0 and target.role == "loyalist"
  end,
  on_cost = Util.TrueFunc,
  on_use = function (self, event, target, player, data)
    data.extra_data = data.extra_data or {}
    data.extra_data.skip_reward_punish = true
  end,
}
efengqi__zongyi.isHiddenSkill = true
yuanshao:addSkill(efengqi__zongyi)

table.insert(Fk.lords, "efengqi__yuanshao")

Fk:loadTranslationTable{
  ["efengqi__yuanshao"] = "袁绍",
  ["#efengqi__yuanshao"] = "高贵的名门",
  ["designer:efengqi__yuanshao"] = "隐匿",
  ["illustrator:efengqi__yuanshao"] = "",

  ["efengqi__qunni"] = "群逆",
  [":efengqi__qunni"] = "你可以将两张牌当【群逆纵逸】使用，且你视为伤害来源；你因此杀死角色后，你获得中央区一张牌。",
  ["#efengqi__qunni"] = "群逆：将两张牌当【群逆纵逸】使用，且你视为伤害来源",
  ["#efengqi__qunni_trigger"] = "群逆",

  ["efengqi__zongyi"] = "纵逸",
  [":efengqi__zongyi"] = "隐匿，你杀死忠臣后无须执行奖惩。",

  ["$efengqi__qunni1"] = "弓箭手，准备放箭！",
  ["$efengqi__qunni2"] = "全都去死吧！",
  ["~efengqi__yuanshao"] = "孟德此计，防不胜防……",
}







return extension
